﻿//-----------------------------------------------------------------------
// <copyright file="ClientPackets.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using System.Runtime.InteropServices;

#endregion

namespace GateShift.Common.DataPackets.Authentication
{
    /// <summary>
    /// DataPacket used to request a username check
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    [Serializable]
    public struct ClientUserNameResponsePacket : IDataPacket
    {
        /// <summary>
        /// Response code on the next step to perform
        /// </summary>
        public ClientUserNameResponseCode ResponseCode;

        /// <summary>
        /// Challenge code used for hashing purposes
        /// </summary>
        public byte[] ChallengeCode;

        /// <summary>
        /// Salt used to help hash the password better
        /// </summary>
        public byte[] PasswordSalt;
    }

    /// <summary>
    /// DataPacket used to request a login verification
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    [Serializable]
    public struct ClientValidationResponsePacket : IDataPacket
    {
        /// <summary>
        /// Response code on the next step to perform
        /// </summary>
        public ClientValidationResponseCode ResponseCode;

        /// <summary>
        /// TimeSpan until the next renewal is due
        /// </summary>
        public TimeSpan TokenLeaseTime;

        /// <summary>
        /// Utc DateTime the server is currently operating at
        /// </summary>
        public DateTime ServerDateTime;

        /// <summary>
        /// Token for this session
        /// </summary>
        public byte[] SessionToken;
    }

    /// <summary>
    /// DataPacket used to respond for a logout
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    [Serializable]
    public struct ClientLogoutResponsePacket : IDataPacket
    {
        /// <summary>
        /// Response code on why the client logged out
        /// </summary>
        public ClientLogoutResponseCode ResponseCode;

        /// <summary>
        /// Reason why the client was logged out
        /// </summary>
        public string Description;
    }
}
